<template>
	<view class="container">
		<!-- <view class="list-cell b-b m-t" @click="navTo('个人资料')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">个人资料</text>
			<text class="cell-more yticon icon-you"></text>
		</view> -->
		<!-- <view class="list-cell b-b" @click="navTo('/pages/address/address')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">收货地址</text>
			<text class="cell-more yticon icon-you"></text>
		</view> -->
		<!-- <view class="list-cell" @click="navTo('')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">实名认证</text>
			<text class="cell-more yticon icon-you"></text>
		</view> -->
		<!-- <view class="list-cell m-t b-b" @click="clear" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">清除缓存</text>
			<text class="cell-more yticon icon-you"></text>
		</view> -->
		<view class="list-cell"  @click="clear"  hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">清除缓存</text>
			<text class="cell-more yticon icon-you"></text>
		</view>
		<view v-if="to" class="list-cell" @click="navTo('/pagesun/set/idea/idea')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">意见反馈</text>
			<text class="cell-more yticon icon-you"></text>
		</view>
		<view class="list-cell" @click="navTo('/pagesun/set/me/me')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">关于我们</text>
			<text class="cell-more yticon icon-you"></text>
		</view>
		<view class="list-cell" @click="navTo('/pagesun/set/versions/versions')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">版本说明</text>
			<text class="cell-more yticon icon-you"></text>
		</view>
		<view class="list-cell">
			<text class="cell-tit" @click="update">检查更新</text>
			<text class="cell-more yticon icon-you"></text>
		</view>
		<!-- <view class="list-cell" @click="navTo('')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">好评鼓励</text>
			<text class="cell-more yticon icon-you"></text>
		</view> -->
		
		<!-- <view class="list-cell m-t">
			<text class="cell-tit">消息推送</text>
			<switch checked color="#E02E24" @change="switchChange" />
		</view> -->
		
		
		
		<view v-if="to" class="list-cell log-out-btn" @click="toLogout">
			<text class="cell-tit">退出登录</text>
		</view>
	</view>
</template>

<script>
	import {  
	    mapMutations  
	} from 'vuex';
	export default {
		data() {
			return {
				to:false,
			};
		},
		onLoad() {
			if(uni.getStorageSync('userInfo').TOKEN){
				this.to=true
			}
			uni.startPullDownRefresh();
		},
		onPullDownRefresh() {
			console.log('refresh');
			setTimeout(function () {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		methods:{
			...mapMutations(['logout']),
			clear(){
				try{
					uni.clearStorage();
					uni.showToast({
						title: "清除缓存成功",
					})
					setTimeout(function () {
						uni.reLaunch({
							url:"/pages/index/index"
						})
					}, 1000);
					
				}catch(e){
					uni.showToast({
						title: "清除缓存失败",
						icon:'none'
					})
				}
				
				
			},
			navTo(url){
				// this.$api.msg(`跳转到${url}`);
				uni.navigateTo({
					url,
				})
				
			},
			//退出登录
			toLogout(){
				uni.showModal({
				    content: '确定要退出登录么',
				    success: (e)=>{
				    	if(e.confirm){
							console.log(e);
				    		this.logout();
				    		setTimeout(()=>{
				    			uni.reLaunch({
				    				url: '/pages/index/index'
				    			})
				    		}, 200)
				    	}
				    }
				});
			},
			//switch
			switchChange(e){
				let statusTip = e.detail.value ? '打开': '关闭';
				this.$api.msg(`${statusTip}消息推送`);
			},
			//检查更新
			update(){
				
			}
		}
	}
</script>

<style lang='scss'>
	page{
		background: $page-color-base;
	}
	.container{
		margin-top: 20upx;
	}
	.list-cell{
		display:flex;
		align-items:baseline;
		padding: 20upx $page-row-spacing;
		line-height:60upx;
		position:relative;
		background: #fff;
		justify-content: center;
		border-bottom: 1upx solid #f5f5f5;
		border-top: 1upx solid #f5f5f5;
		&.log-out-btn{
			margin-top: 40upx;
			.cell-tit{
				color: #E02E24;
				text-align: center;
				margin-right: 0;
			}
		}
		&.cell-hover{
			background:#fafafa;
		}
		&.b-b:after{
			left: 30upx;
		}
		&.m-t{
			margin-top: 16upx; 
		}
		.cell-more{
			align-self: baseline;
			font-size:$font-lg;
			color:$font-color-light;
			margin-left:10upx;
		}
		.cell-tit{
			flex: 1;
			font-size: $font-base + 2upx;
			color: $font-color-dark;
			margin-right:10upx;
		}
		.cell-tip{
			font-size: $font-base;
			color: $font-color-light;
		}
		switch{
			transform: translateX(16upx) scale(.84);
		}
	}
</style>
